class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2022-10-18",
      revision: "b4e29f1fae9fe4aaced5ae0d18ffce260a8165ff"
  version "2022-10-18"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git", branch: "master"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_monterey: "4a3a012215eebaa35269df2a1216343d95d4fd58a214af6fd81936776ed68be7"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "a3f8ada0fd4417ccc56ee53d8c0dcd12b050ed3ed009f9d6c42b2bf2793d6441"
    sha256 cellar: :any_skip_relocation, monterey:       "1000d4b86e47f78d307bca03c76b73b741dcebfecea838f99eece7bcf9b1654b"
    sha256 cellar: :any_skip_relocation, big_sur:        "d8d3165387fe2f52f5225143d5f616e19c2fe0808d6721f9ef59988a77baa88b"
    sha256 cellar: :any_skip_relocation, catalina:       "dd2e1974aa4d98334d3a96136906145f4de1d2a27a6fcda6b58fd1e7ccaefb94"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "76c7cfa3af8d702675ce0064c7d04fc077ca65c296cb640ee1a63dfe5a5ee36e"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
